package com.test.ayi.test.competablefuture;

import java.util.concurrent.CompletableFuture;

public class CFtest3Combine {
    public static void main(String[] args) throws InterruptedException {
        CompletableFuture<String> greenOnion =
                CompletableFuture.supplyAsync(() -> "葱花");
        CompletableFuture<String> garlic =
                CompletableFuture.supplyAsync(() -> "蒜泥");

        CompletableFuture<String> seasoning =
                greenOnion.thenCombine(garlic, (a, b) -> a + " & " + b);

        System.out.println(seasoning.join()); // 葱花 & 蒜泥

    }
}
